home *** CD-ROM | disk | FTP | other *** search
/ Collection of Tools & Utilities / Collection of Tools and Utilities.iso / tex / ptf12.zip / PTFTEST.SRC < prev   
Text File  |  1990-02-27  |  34KB  |  1,423 lines

  1. --::::::::::
  2. --ptftest.inc
  3. --::::::::::
  4. -- This include file
  5. ptftest.inc
  6.  
  7. -- Test programs for PTF
  8. err_test.a
  9. foftest1.a
  10. foftest2.a
  11. foftest3.a
  12. foftest4.a
  13. mac_test.a
  14. parsetst.a
  15. var_test.a
  16. wp_test.a
  17.  
  18. -- Test data files
  19. foftest2.inp
  20. wptest1.in
  21. wptest2.in
  22. wptest2a.in
  23. wptest2b.in
  24. wptest3.in
  25. wptest4.in
  26. wptest5.in
  27. wptest6.in
  28. --::::::::::
  29. --err_test.a
  30. --::::::::::
  31. -- ..................................
  32. -- .                                .
  33. -- .  Err_Test                      .  SPEC & BODY
  34. -- .                                .
  35. -- ..................................
  36. with Console;
  37. with Error_Log;
  38. with Variable;
  39. procedure Err_Test is
  40.  
  41. --| Purpose
  42. --| Err_Test provides a simple test of the Error_Log package.
  43. --|
  44. --| Exceptions (none)
  45. --| Notes (none)
  46. --|
  47. --| Modifications
  48. --| 08/23/89  Rick Conn    Initial Version
  49.  
  50. begin -- Err_Test
  51.  
  52.   Variable.Set_File_Name("Err_Test");
  53.   Variable.Set_Line_Number(1);
  54.  
  55.   Error_Log.Write_Error("This message should go to the console");
  56.   Error_Log.Write_Warning("This message also");
  57.   Error_Log.Close;
  58.  
  59.   Error_Log.Open("error.log");
  60.   Error_Log.Write_Error("this message appears in the error log file");
  61.   Error_Log.Write_Warning("as does this one");
  62.   Error_Log.Close;
  63.  
  64.   Console.Put_Line("Test complete -- output on screen and in error.log");
  65.  
  66. end Err_Test;
  67. --::::::::::
  68. --foftest1.a
  69. --::::::::::
  70. -- ..................................
  71. -- .                                .
  72. -- .  Foftest1                      .  SPEC & BODY
  73. -- .                                .
  74. -- ..................................
  75. with Console;
  76. with Formatted_Output_File;
  77. use Formatted_Output_File;
  78. with Text_IO;
  79. procedure Foftest1 is
  80.  
  81. --| Purpose
  82. --| FofTest1 is a basic test program for the Formatted_Output_File
  83. --| package.  It exercises the Put_Line and Break_Page routines
  84. --| primarily.
  85. --|
  86. --| Notes (none)
  87. --|
  88. --| Modifications
  89. --| 8/1/89  Rick Conn    Initial version
  90.  
  91.   Output_File
  92.     : Formatted_Output_File.File;
  93.  
  94.   File_Name
  95.     : constant STRING
  96.       := "foftest1.doc";
  97.  
  98.   Open_Status
  99.     : Formatted_Output_File.Status;
  100.  
  101. begin -- Foftest1
  102.  
  103.   -- Open the output file
  104.   Open(Output_File, File_Name, Open_Status);
  105.  
  106.   -- Check for status of open
  107.   if Open_Status = Not_Ok then
  108.     Text_IO.Put_Line("Cannot open output file");
  109.   end if;
  110.  
  111.   -- Set margins
  112.   Set_Page_Attribute(Output_File, Left_Margin, 10);
  113.   Set_Page_Attribute(Output_File, Right_Margin, 70);
  114.  
  115.   -- Set header lines
  116.   Set_Page_Attribute(Output_File, Header_Lines, 2);
  117.   Set_Header_Line(Output_File, Even_Pages, 1, "", "", "File Name: "
  118.       & File_Name);
  119.   Set_Header_Line(Output_File, Odd_Pages, 1,
  120.       "File Name: " & File_Name, "", "");
  121.   Set_Header_Line(Output_File, All_Pages, 2, "", "", "");
  122.  
  123.   -- Set footer lines
  124.   Set_Page_Attribute(Output_File, Footer_Lines, 2);
  125.   Set_Footer_Line(Output_File, All_Pages, 1, "", "", "");
  126.   Set_Footer_Line(Output_File, Even_Pages, 2, "Page #", "", "");
  127.   Set_Footer_Line(Output_File, Odd_Pages, 2, "", "", "Page #");
  128.  
  129.   -- Set No FILL
  130.   Set_Line_Attribute(Output_File, Fill, Off);
  131.  
  132.   -- Output 2 lines of numbers
  133.   Put_Line(Output_File,
  134.       "         1         2         3         4         5         6");
  135.   Put_Line(Output_File,
  136.       "1234567890123456789012345678901234567890123456789012345678901");
  137.  
  138.   -- Output 46 lines on the first page
  139.   for I in 1 .. 46 loop
  140.     Put_Line(Output_File, "Page 1, Line Number" & INTEGER'Image(I + 2));
  141.   end loop;
  142.  
  143.   -- Output 2 lines of numbers
  144.   Put_Line(Output_File,
  145.       "         1         2         3         4         5         6");
  146.   Put_Line(Output_File,
  147.       "1234567890123456789012345678901234567890123456789012345678901");
  148.  
  149.   -- Go to next page
  150.   Break_Page(Output_File);
  151.  
  152.   -- Output 2 lines of numbers
  153.   Put_Line(Output_File,
  154.       "         1         2         3         4         5         6");
  155.   Put_Line(Output_File,
  156.       "1234567890123456789012345678901234567890123456789012345678901");
  157.  
  158.   -- Output 46 lines on the second page
  159.   for I in 1 .. 46 loop
  160.     Put_Line(Output_File, "Page 2, Line Number" & INTEGER'Image(I + 2));
  161.   end loop;
  162.  
  163.   -- Output 2 lines of numbers
  164.   Put_Line(Output_File,
  165.       "         1         2         3         4         5         6");
  166.   Put_Line(Output_File,
  167.       "1234567890123456789012345678901234567890123456789012345678901");
  168.  
  169.   -- Go to next page (Break_Page call is not really necessary)
  170.   -- Break_Page(Output_File);
  171.  
  172.   -- Output many lines on the third and following pages
  173.   for I in 1 .. 100 loop
  174.     Put_Line(Output_File, "Long List, Line Number" & INTEGER'Image(I));
  175.   end loop;
  176.  
  177.   -- Close the output file
  178.   Close(Output_File);
  179.  
  180.   Console.Put_Line("Test complete -- output in " & File_Name);
  181.  
  182. end Foftest1;
  183. --::::::::::
  184. --foftest2.a
  185. --::::::::::
  186. -- ..................................
  187. -- .                                .
  188. -- .  Foftest2                      .  SPEC & BODY
  189. -- .                                .
  190. -- ..................................
  191. with Console;
  192. with Formatted_Output_File;
  193. use Formatted_Output_File;
  194. with Text_IO;
  195. procedure Foftest2 is
  196.  
  197. --| Purpose
  198. --| FofTest2 is a basic test program for the Formatted_Output_File
  199. --| package.  It tests the Put_Word, Skip_Line, and Break_Line
  200. --| routines primarily.
  201. --|
  202. --| Notes (none)
  203. --|
  204. --| Modifications
  205. --| 08/04/89  Rick Conn    Initial version
  206.  
  207.   Input_File
  208.     : Text_IO.File_Type;
  209.  
  210.   Output_File
  211.     : Formatted_Output_File.File;
  212.  
  213.   Input_File_Name
  214.     : constant STRING
  215.       := "foftest2.inp";
  216.  
  217.   Output_File_Name
  218.     : constant STRING
  219.       := "foftest2.doc";
  220.  
  221.   Open_Status
  222.     : Formatted_Output_File.Status;
  223.  
  224.   Inline
  225.     : STRING (1 .. 100);
  226.  
  227.   Inlast
  228.     : NATURAL;
  229.  
  230.   First
  231.     : NATURAL;
  232.  
  233.   Last
  234.     : NATURAL;
  235.  
  236.   Current
  237.     : NATURAL;
  238.  
  239.   Program_Halt
  240.     : exception;
  241.  
  242.   procedure Process is
  243.  
  244.   begin -- Process
  245.  
  246.   -- Open the input file
  247.     Text_IO.Open(Input_File, Text_IO.In_File, Input_File_Name);
  248.  
  249.     -- Main loop
  250.     Skip(Output_File, 2);
  251.     Put_Word(Output_File, "     ");              -- start 1st paragraph
  252.     while not Text_IO.End_Of_File(Input_File) loop
  253.       Text_IO.Get_Line(Input_File, Inline, Inlast);
  254.       if Inlast = 0 then
  255.         -- Begin a new paragraph (with opening spaces) if a blank line
  256.         Skip(Output_File, 2);
  257.         Put_Word(Output_File, "     ");
  258.       else
  259.         -- Extract the next word from the input line and
  260.         -- output this word to the formatted file
  261.         Current        := 1;
  262.         while Current <= Inlast loop
  263.           First          := Inlast + 1;
  264.           for I in Current .. Inlast loop
  265.             if Inline(I) > ' ' then
  266.               First          := I;
  267.               exit;
  268.             end if;
  269.           end loop;
  270.           Current        := Inlast + 1;
  271.           if First <= Inlast then
  272.             Last           := Inlast;
  273.             for I in First .. Inlast loop
  274.               if Inline(I) <= ' ' then
  275.                 Last           := I - 1;
  276.                 exit;
  277.               end if;
  278.             end loop;
  279.             Put_Word(Output_File, Inline(First .. Last));
  280.             Current        := Last + 1;
  281.           end if;
  282.         end loop;
  283.       end if;
  284.     end loop;
  285.  
  286.     -- End page
  287.     Break_Page(Output_File);
  288.  
  289.     -- Close the input file
  290.     Text_IO.Close(Input_File);
  291.  
  292.   end Process;
  293.  
  294. begin -- Foftest2
  295.  
  296.   -- Open the output file
  297.   Open(Output_File, Output_File_Name, Open_Status);
  298.  
  299.   -- Check for status of open
  300.   if Open_Status = Not_Ok then
  301.     Text_IO.Put_Line("Cannot open output file");
  302.     raise Program_Halt;
  303.   end if;
  304.  
  305.   -- Set margins
  306.   Set_Page_Attribute(Output_File, Left_Margin, 10);
  307.   Set_Page_Attribute(Output_File, Right_Margin, 70);
  308.  
  309.   -- Set header lines
  310.   Set_Page_Attribute(Output_File, Header_Lines, 2);
  311.   Set_Header_Line(Output_File, All_Pages, 1, "", "File Name: " &
  312.       Output_File_Name, "");
  313.   Set_Header_Line(Output_File, All_Pages, 2, "", "", "");
  314.  
  315.   -- Set footer lines
  316.   Set_Page_Attribute(Output_File, Footer_Lines, 2);
  317.   Set_Footer_Line(Output_Fil